<?php

Raise::load('core.exception.RaiseException');

/**
 * TestException class
 * Testing unit of 'phpraise/exception/*Exception.php'
 *
 * @author Sam-Mauris Yong / hellclanner at live dot com
 * @license http://www.opensource.org/licenses/bsd-license New BSD License
 * @package Raise.UnitTest.Test
 */
class TestException extends RaiseTest{

    public static function testExistence(){
        self::assertClassExists('RaiseException');
        self::exceptionUnit('RaiseInvalidArgumentException', 10001);
        self::exceptionUnit('RaiseInvalidRequestException', 10002);
        self::exceptionUnit('RaiseFileNotFoundException', 40003);
        self::exceptionUnit('RaiseFileOperationFailedException', 40004);
        self::exceptionUnit('RaiseNotImplementedException', 10005);
        self::exceptionUnit('RaiseRemoteConnectionException', 40006);
        self::exceptionUnit('RaiseNetworkOperationFailedException', 40007);
        self::exceptionUnit('RaiseNullArgumentException', 30008);
        self::exceptionUnit('RaiseClientIdExistException', 20009);
        self::exceptionUnit('RaiseStaticClassConstructionException', 30010);
        self::exceptionUnit('RaiseDOMParseException', 20011);
        self::exceptionUnit('RaiseIncompatiblePluginException', 10012);
        self::exceptionUnit('RaiseUserAccessDeniedException', 10014);
        self::exceptionUnit('RaisePageNotFoundException', 30015);
        self::exceptionUnit('RaiseNoConnectionMadeException', 10016);
        self::exceptionUnit('RaiseZipException', 30017);
        self::exceptionUnit('RaiseInvalidConfigurationException', 30018);
        self::exceptionUnit('RaisePostbackException', 30019);
        self::exceptionUnit('RaiseDatabaseException', 30020);
        self::exceptionUnit('RaiseDatabaseSQLException', 30021);
        self::exceptionUnit('RaiseModelKeyMismatchException', 10022);
    }
    
    private static function exceptionUnit($class, $code){
        self::assertClassExists('RaiseModelKeyMismatchException');
        $message = 'Testing Exception Message';
        $exception = new $class($message);
        self::assertTrue($exception instanceof RaiseException);
        self::assertTrue($exception instanceof Exception);
        self::assertObjectClass($exception, $class);
        self::assertStrictEqual($exception->getCode(), $code);
        self::assertStrictEqual($exception->getMessage(), $message);
    }
    
    
}
